// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'package:flutter/material.dart';

import 'package:junyeyishu/utils/utils.dart';
import 'package:junyeyishu/widgets/QGWidget.dart';
import 'package:junyeyishu/widgets/QGListState.dart';

class QGColrfulSynthesisRecordPage extends StatefulWidget {
  String id;
  QGColrfulSynthesisRecordPage({super.key, required this.id});
  @override
  State<QGColrfulSynthesisRecordPage> createState() =>
      _QGColrfulSynthesisRecordPageState();
}

class _QGColrfulSynthesisRecordPageState
    extends QGListState<QGColrfulSynthesisRecordPage> {
  @override
  void initState() {
    super.initState();

    listURL = url_synthesis_getMyCombineLog;
    listKey = "list";

    onRefresh();
  }

  @override
  Map listParam() {
    return {"id": widget.id};
  }

  @override
  Widget build(BuildContext context) {
    return QGScaffold(
        title: '合成记录',
        bgColor: Color(0xFFF8F8F6),
        body: Column(children: [SizedBox(height: 10.rpx), buildList()]));
  }

  @override
  Widget itemBuilder(context, index, dynamic itemData) {
    return Stack(
      children: [
        Container(
          margin: EdgeInsets.only(bottom: 10.rpx, left: 10.rpx, right: 10.rpx),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(6.rpx),
            color: Color(0xFFFFFFFF),
          ),
          padding: EdgeInsets.all(15.rpx),
          child: Row(
            children: [
              ClipRRect(
                borderRadius: BorderRadius.circular(4.rpx),
                child: QGImage(
                    url: itemData?["thumb_img"], width: 80.rpx, height: 80.rpx),
              ),
              SizedBox(width: 15.rpx),
              Expanded(child: buildText(itemData["name"] ?? "")),
            ],
          ),
        ),
      ],
    );
  }

  buildText(name) {
    return Container(
      margin: EdgeInsets.only(bottom: 5.rpx, top: 5.rpx),
      child: Text(
        name,
        style: TextStyle(
            color: Color(0xFF111111),
            fontSize: 14.rpx,
            fontWeight: FontWeight.bold),
      ),
    );
  }
}
